/**
 */
import {getAction, postAction} from '@/api/manage'

export const butStatus = {
  data() {
    return {
      // 2 为待审核，9 为已审核
      status: '',

      approveStatus: '',
      dataSource: []
    }
  },
  created() {
  },
  mounted() {
  },
  methods: {
    getStstus() {
      getAction(this.url.butStatus, {proId: this.model.id, typeId: this.typeId}).then((res) => {
        if (res.success) {
          this.status = res.applyStatus
        } else {
          this.$message.error(res.message)
        }
      })
    },
    showShjl() {
      this.$refs.shjlModal.show()
    },
    // 提交审核-打开选择审核人弹窗
    showConfirm() {
      this.$refs.approver.show()
    },
    // 提交审核
    handleSubmit(userId) {
      getAction(this.url.submit, {
        proId: this.model.id,
        userId: userId,
        typeId: this.typeId
      }).then((res) => {
        if (res.success) {
          this.$message.success(res.message)
          this.close()
        } else {
          this.$message.error(res.message)
        }
      })
    },
    // 填写审核原因
    setApproveReason(status) {
      this.approveStatus = status
      this.$refs.setReason.show()
    },
    // 同意拒绝
    approveData(reason) {
      let remark = this.approveStatus === '9' ? `同意：${reason}` : `拒绝：${reason}`
      getAction(this.url.approve, {
        proId: this.model.id,
        status: this.approveStatus,
        remark: remark,
        typeId: this.typeId
      }).then((res) => {
        if (res.success) {
          this.$refs.setReason.setApproveReason = false
          this.$emit('ok')
          this.close()
        } else {
          this.$message.error(res.message)
        }
      })
    }
  }

}